// 用来维护每个路由(地址) => 每一个组件(页面)的映射关系
// import Home from "../pages/home.vue";
const routes = [
  //书写一个映射关系
  // 先配置好容器组件
  {
    path: "/",
    component: () => import("../layout/index.vue"),
    // 重定向
    redirect: () => {
      //判断他是不是登录
      // localStorage  本地存储
      let isLogin = localStorage.getItem("isLogin");
      if (!isLogin) {
        return "/login";
      } else {
        return "/home";
      }
    },
    children: [
      {
        path: "/home",
        component: () => import("../pages/home.vue"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("../pages/loging.vue"),
  },
];

export default routes;
